package xeichengbishi;
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
/**
 * Created by JiaJia on 2019/9/4 0004.
 */
public class Xiecheng01 {
    public static class ListNode {
        int val;
        ListNode next;
        ListNode(int x) {
            val = x;
            next = null;
        }
    }

    /*请完成下面这个函数，实现题目要求的功能
    ******************************开始写代码******************************/
    static ListNode partition(ListNode head,int m) {
        Queue<Integer> queue1=new LinkedList<>();
        Queue<Integer> queue2=new LinkedList<>();
        while (head!=null){
            if (head.val<=m){
                queue1.add(head.val);
            }else {
                queue2.add(head.val);
            }
            head=head.next;
        }
        ListNode pHead=new ListNode(-1);
        ListNode newHead=new ListNode(queue1.isEmpty()?queue2.poll():queue1.poll());
        pHead.next=newHead;
        while (!queue1.isEmpty()){
            newHead.next=new ListNode(queue1.poll());
            newHead=newHead.next;
        }
        while (!queue2.isEmpty()){
            newHead.next=new ListNode(queue2.poll());
            newHead=newHead.next;
        }
        return pHead.next;
    }
    /******************************结束写代码******************************/


    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        ListNode head=null;
        ListNode node=null;
        int m=in.nextInt();
        while(in.hasNextInt()){
            int v=in.nextInt();
            if(head==null){
                node=new ListNode(v);
                head=node;
            }else{
                node.next=new ListNode(v);
                node=node.next;
            }
        }
        head= partition(head,m);
        if(head!=null){
            System.out.print(head.val);
            head=head.next;
            while(head!=null){
                System.out.print(",");
                System.out.print(head.val);
                head=head.next;
            }
        }
        System.out.println();
    }

}